package com.tencent.wxcloudrun.utils;


import com.tencent.wxcloudrun.common.Result;
import com.tencent.wxcloudrun.exception.CommonErrorEnum;
import com.tencent.wxcloudrun.exception.ErrorCode;

public class ResultUtil {
    public ResultUtil() {
    }

//    public static <T> Result<T> suc(T data) {
//        return new Result(CommonErrorEnum.SUC.getEc(), (String)null, data);
//    }

    public static <T> Result<T> error(int ec, String em) {
        return new Result(ec, em);
    }

    public static <T> Result<T> error(ErrorCode errorCode, Object... params) {
        return new Result(errorCode.getEc(), ErrorCode.getDescribe(errorCode, params));
    }






    public static <T> Result<T> message(Integer code, String message, T data) {
        return new Result<>(code, message, data);
    }

    public static <T> Result<T> message(Integer code, String message) {
        return new Result<>(code, message);
    }


    public static <T> Result<T> success() {
        return new Result<>(CommonErrorEnum.SUC.getEc(), CommonErrorEnum.SUC.getEm());
    }


    public static <T> Result<T> successData(T data) {
        return new Result<>(CommonErrorEnum.SUC.getEc(), CommonErrorEnum.SUC.getEm(), data);
    }
}
